home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 25 / AACD 25.iso / AACD / Programming / PtnAsm / mandel.p < prev    next >
Encoding:
Text File  |  1980-04-14  |  7.1 KB  |  344 lines

  1. ********************************************
  2.  
  3.         incdir  "asminclude:"
  4.         include "lvos/powerpc_lib.i"
  5.         include "lvos/intuition_lib.i"
  6.         include "lvos/graphics_lib.i"
  7.         include "lvos/exec_lib.i"
  8.         include "lvos/dos_lib.i"
  9.         include "powerpc/memoryppc.i"
  10.         include "powerpc/powerpc.i"
  11.         include "powerpc/ppcmacros.i"
  12.         include "intuition/intuition.i"
  13.  
  14. ********************************************
  15.  
  16.  
  17.         xdef        _main
  18.         xref        _PowerPCBase
  19.         xref        _DOSBase
  20.         xref        _SysBase
  21.  
  22.         escapestr   1
  23.  
  24. lastr:  macro
  25.         save
  26.         section  "strings",data
  27. \@      cstring   "\2"
  28.         restore
  29.         \1    =     &\@
  30.         endm
  31.  
  32. call_exec: macro
  33.            run68k_xl   _SysBase,\1
  34.            tstw        _d0
  35.            endm
  36.  
  37. call_int:  macro
  38.            run68k_xl   _IntuitionBase,\1
  39.            tstw        _d0
  40.            endm
  41.  
  42. call_graf: macro
  43.            run68k_xl   _GfxBase,\1
  44.            tstw        _d0
  45.            endm
  46.  
  47. call_dos:  macro
  48.            run68k_xl   _DOSBase,\1
  49.            tstw        _d0
  50.            endm
  51.  
  52. OS_VER     equ      40
  53.  
  54. ********************************************
  55.  
  56. _main:
  57.         prolog
  58.         *_stack     = stack
  59.  
  60.         bl          _open_libs
  61.         bl          _init_screen
  62.  
  63.         bl          _draw
  64.         bl          _display
  65.         bl          _clean_up
  66.         epilog
  67.  
  68. _exit:
  69.         prolog
  70.         stack       = *_stack
  71.         epilog
  72.  
  73. ********************************************
  74. _display:
  75.         prolog      PP_SIZE+20
  76.  
  77.         _d7         =  0
  78. .loop:
  79.         _a0         =  *_vp
  80.         _d0         =  _d7
  81.         _d1         =  shiftl(_d7,24)
  82.         _d2         =  _d1
  83.         _d3         =  _d1
  84.         call_graf   SetRGB32
  85.  
  86.         _d7         =  _d7 + 1
  87.         cmpw(_d7,256)
  88.         blt         .loop
  89.  
  90.         _a0         =  *_rp
  91.         _d0         =  0
  92.         _d1         =  0
  93.         _d2         =  *_width.w
  94.         _d3         =  *_height.w
  95.         _d4         =  *_width.w
  96.         _a2         =  *_chunky
  97.         _d2         =  _d2 - 1
  98.         _d3         =  _d3 - 1
  99.         call_graf   WriteChunkyPixels
  100.  
  101.  
  102.         epilog
  103.  
  104. ********************************************
  105.  
  106. _error_int:
  107.         lastr       _d1,<Can't open intuition.library\n>
  108.         b           _print_error
  109. _error_gfx:
  110.         lastr       _d1,<Can't open dos.library\n>
  111.         b           _print_error
  112. _error_mem:
  113.         lastr       _d1,<Not enought memory\n>
  114.         b           _print_error
  115. _error_screen:
  116.         lastr       _d1,<Can't open screen\n>
  117.         b           _print_error
  118.  
  119.  
  120. _print_error:
  121.         prolog      PP_SIZE+20
  122.         call_dos    PutStr
  123.         b           _exit
  124.         epilog
  125. ********************************************
  126. _open_libs:
  127.         prolog      PP_SIZE+20
  128.  
  129.         lastr       _a1,<intuition.library>
  130.         _d0         =  OS_VER
  131.         call_exec   OpenLibrary
  132.         beq         _error_int
  133.         *_IntuitionBase   =  _d0
  134.  
  135.         lastr       _a1,<graphics.library>
  136.         _d0         =  OS_VER
  137.         call_exec   OpenLibrary
  138.         beq         _error_gfx
  139.         *_GfxBase   =  _d0
  140.  
  141.  
  142.         epilog
  143.  
  144. ********************************************
  145. _init_screen:
  146.         prolog      PP_SIZE+20
  147.         _a0         =     0
  148.         _a1         =     &_screen_tags
  149.         call_int    OpenScreenTagList
  150.         beq         _error_screen
  151.         *_screen    =  _d0
  152.  
  153.         _d1         =  sc_Width(_d0.w)
  154.         _d2         =  sc_Height(_d0.w)
  155.         _d3         =  _d0 + sc_RastPort
  156.         _d4         =  _d0 + sc_ViewPort
  157.  
  158.         *_width.w   =  _d1
  159.         *_height.w  =  _d2
  160.         *_rp        =  _d3
  161.         *_vp        =  _d4
  162.  
  163.         r4          =  _d1 * _d2
  164.         r5          =  MEMF_ANY
  165.         r6          =  0
  166.         callpowerpc AllocVecPPC
  167.         tstw        r3
  168.         beq         _error_mem
  169.         *_chunky    =  r3
  170.         epilog
  171.  
  172.         save
  173.         data
  174.  
  175. _screen_tags: 
  176.         dc.l     SA_LikeWorkbench,1
  177.         dc.l     SA_Depth,8
  178.         dc.l     SA_Type,CUSTOMSCREEN
  179.         dc.l     SA_AutoScroll,1
  180.         dc.l     TAG_DONE
  181.  
  182.         restore
  183.  
  184. ********************************************
  185.  
  186. deltax        fsetr    f29
  187. deltay        fsetr    f28
  188. x             fsetr    f27
  189. y             fsetr    f26
  190. a             fsetr    f25
  191. old_a         fsetr    f24
  192. bi            fsetr    f23
  193. r             fsetr    f22
  194. zero          fsetr    f21
  195. lenght_z      fsetr    f20
  196. temp1         fsetr    f19
  197. temp2         fsetr    f18
  198.  
  199. chunky        setr     r31
  200. loop_y        setr     r30
  201. loop_x        setr     r29
  202. iterations   setr     r28
  203.  
  204. _draw:
  205.         prolog
  206.  
  207.         r3       =  *_width.w
  208.         bl       _citf
  209.         f31      =  f1
  210.         r3       =  *_height.w
  211.         bl       _citf
  212.         f30      =  f1
  213.  
  214.         x        =  *_min_x.s
  215.         y        =  *_min_y.s
  216.         f1       =  *_max_x.s
  217.         f2       =  *_max_y.s
  218.         chunky   =  *_chunky
  219.         chunky   =  chunky - 1  ;for stbu
  220.  
  221.         deltax   =  f1 - x
  222.         deltay   =  f2 - y
  223.         deltax   =  deltax / f31
  224.         deltay   =  deltay / f30
  225.         r        =  *_r.s
  226.         zero     =  *_zero.s
  227.  
  228.         loop_y   =  *_height.w
  229. .loop_y:
  230.         loop_x   =  *_width.w
  231.         x        =  *_min_x.s
  232. .loop_x:
  233.         a        =  zero
  234.         bi       =  zero
  235.         iterations =  0
  236.  
  237. .loop:
  238.         old_a    =  a
  239.  
  240.         temp1    =  bi * bi + x
  241.         temp2    =  bi * a + y
  242.  
  243.         a        =  a * a - temp1
  244.         bi       =  temp2 + temp2
  245.  
  246.         temp1    =  a*a
  247.         iterations = iterations + 1
  248.         lenght_z =  bi*bi + temp1
  249.  
  250.         fcmpu(lenght_z,r)
  251.         bgt      .put_pixel
  252.  
  253.         cmpw(iterations,128)
  254.         bgt      .put_pixel
  255.         b        .loop
  256.  
  257. .put_pixel:
  258.  
  259.         1[chunky.b] =  iterations
  260.  
  261.         x        =  x  +  deltax
  262.  
  263.         loop_x   =  loop_x - 1
  264.         tstw     loop_x
  265.         bgt+     .loop_x
  266.  
  267.         y        =  y  +  deltay
  268.         loop_y   =  loop_y - 1
  269.         tstw     loop_y
  270.         bgt+     .loop_y
  271.  
  272.  
  273.  
  274.  
  275.         epilog
  276.  
  277.         save
  278.         data
  279.  
  280.         align.s
  281. _min_x:    dc.s  -2
  282. _max_x:    dc.s  1.25
  283. _min_y:    dc.s  -1.25
  284. _max_y:    dc.s  1.25
  285. _zero:     dc.s  0
  286. _r:        dc.s  4
  287.         restore
  288.  
  289. _citf:
  290.          lf      f2,_CITF0
  291.          xoris   trash,r3,$8000
  292.          sw      trash,_CITF_TEMP+4
  293.          lf      f1,_CITF_TEMP
  294.          fsub    f1,f1,f2
  295.          blr
  296.  
  297.          save
  298.          data
  299.  
  300. _CITF0:         dc.l    $43300000,$80000000
  301. _CITF_TEMP      dc.l    $43300000,0
  302.  
  303.          restore
  304.  
  305.  
  306. ********************************************
  307. _close_libs:
  308.         prolog      PP_SIZE+20
  309.  
  310.         epilog
  311.  
  312. _clean_up:
  313.         prolog      PP_SIZE+20
  314.  
  315.         _d1         =  200
  316.         _d0         =  200
  317.         call_dos    Delay
  318.  
  319.         _d0         =  *_screen
  320.         tstw        _d0
  321.         beq         .1
  322.         mr          _a0,_d0
  323.         call_int    CloseScreen
  324. .1:
  325.  
  326.  
  327.         callpowerpc FreeAllMem
  328.         
  329.         bl          _close_libs
  330.         b           _exit
  331.         epilog
  332. ********************************************
  333.  
  334.         bss_f
  335. _stack:          ds.l  1
  336. _IntuitionBase:  ds.l  1
  337. _GfxBase:        ds.l  1
  338. _screen:         ds.l  1
  339. _chunky:         ds.l  1
  340. _vp:             ds.l  1
  341. _rp:             ds.l  1
  342. _height:         ds.w  1
  343. _width:          ds.w  1
  344.